package it.battlehorse.rcp.sl;

import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;

/**
 * The main plugin class which handles the service locator and its life cycle
 */
public class SLActivator extends Plugin {

	//The shared instance.
	private static SLActivator plugin;
	
	// The shared service locator
	private ServiceLocator sloc;
	
	/**
	 * The constructor.
	 */
	public SLActivator() {
		plugin = this;
	}

	/**
	 * This method is called upon plug-in activation
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		
		// Init the shared objects
		sloc = ServiceLocator.getInstance();
	}

	/**
	 * This method is called when the plug-in is stopped
	 */
	public void stop(BundleContext context) throws Exception {
		super.stop(context);
		plugin = null;
	}

	/**
	 * Returns the shared instance.
	 */
	public static SLActivator getDefault() {
		return plugin;
	}
	
	/**
	 * Returns the shared service locator
	 * 
	 * @return the shared service locator
	 */
	public ServiceLocator getServiceLocator()  {
		return sloc;
	}

}
